<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="审核状态" prop="state">
        <!-- <el-input v-model="queryParams.state" placeholder="请选择审核状态" clearable @keyup.enter.native="handleQuery" /> -->
        <el-select v-model="queryParams.state" filterable placeholder="选择审核状态" style="width: 320px">
          <el-option v-for="item in Post_Apply_State.list" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="类型" prop="type">
        <!-- <el-input v-model="queryParams.type" placeholder="请选择类型" clearable @keyup.enter.native="handleQuery" /> -->
        <el-select v-model="queryParams.type" filterable placeholder="选择岗位类型" style="width: 320px">
          <el-option v-for="item in Post_Apply_Type.list" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single"
          @click="handleUpdate" v-hasPermi="['train:PostImproveApplication:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple"
          @click="handleDelete" v-hasPermi="['train:PostImproveApplication:delete']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table border v-loading="loading" :data="PostImproveApplicationList" @selection-change="handleSelectionChange">
      <el-table-column resizable show-overflow-tooltip type="selection" width="55" align="center" />
      <el-table-column resizable show-overflow-tooltip label="岗位" align="center" prop="postName" />
      <el-table-column resizable show-overflow-tooltip label="类型" align="center" prop="type">
        <template v-slot="{ row }">
          {{ Post_Apply_Type.map[row.type] }}
        </template>
      </el-table-column>
      <el-table-column resizable show-overflow-tooltip label="审核状态" align="center" prop="state">
        <template v-slot="{ row }">
          {{ Post_Apply_State.map[row.state] }}
        </template>
      </el-table-column>
      <el-table-column resizable show-overflow-tooltip label="申请人" align="center" prop="applicantName" />
      <el-table-column resizable show-overflow-tooltip label="审核人" align="center" prop="reviewerNName" />
      <el-table-column resizable show-overflow-tooltip label="审核备注" align="center" prop="remark" />
      <el-table-column resizable label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" v-if="scope.row.state == 0" @click="handleUpdate(scope.row)" v-hasPermi="['train:PostImproveApplication:audit']">审核</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改岗位提升申请对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-row>
        <el-form ref="form" :model="form" :rules="rules" label-width="80px">
          <el-col :span="12">
            <el-form-item label="岗位" prop="postId">
              <el-select v-model="form.postId" filterable placeholder="选择岗位能力" :disabled="form.id != null" style="width: 320px">
                <el-option v-for="item in postList" :key="item.postId" :label="item.postName" :value="item.postId" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="类型" prop="type">
              <el-select v-model="form.type" filterable placeholder="选择岗位类型" :disabled="form.id != null" style="width: 320px">
                <el-option v-for="item in Post_Apply_Type.list" :key="item.value" :label="item.label"
                  :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="form.type != 1">
            <el-form-item label="岗位级别" prop="toCode">
              <el-select v-model="form.toCode" filterable placeholder="选择岗位等级" :disabled="form.id != null" style="width: 320px">
                <el-option v-for="item in dict.type.post_level" :key="item.value" :label="item.label"
                  :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="form.type == 1">
            <el-form-item label="岗位能力" prop="toCode">
              <el-select v-model="form.toCode" filterable placeholder="选择岗位能力" :disabled="form.id != null" style="width: 320px">
                <el-option v-for="item in dict.type.post_ability" :key="item.value" :label="item.label"
                  :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实操分数" prop="operationGrade">
              <el-input v-model="form.operationGrade" placeholder="请输入实操分数" :disabled="form.id != null" style="width: 320px" clearale />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="应急分数" prop="emergencyGrade">
              <el-input v-model="form.emergencyGrade" placeholder="请输入应急分数" :disabled="form.id != null" style="width: 320px" clearale />
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="form.id != null">
            <el-form-item label="状态" prop="state">
              <el-switch v-model="form.state" size="large" active-text="通过" active-value="1" inactive-text="驳回" inactive-value="2" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" placeholder="请输入备注" style="width: 320px" clearale />
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script src="./index.js">

</script>
